package main

import (
	"fmt"
	"gopkg.in/yaml.v3"
	"io/ioutil"
)

type Config struct {
	Kafka Kafka `json:"kafka" yaml:"kafka"`
	Mysql Mysql `json:"mysql" yaml:"mysql"`
}

type Kafka struct {
	Server string `json:"server" yaml:"server"`
	Topic  string `json:"topic" yaml:"topic"`
}

type Mysql struct {
	Host     string `json:"host" yaml:"host"`
	Port     int    `json:"port" yaml:"port"`
	User     string `json:"user" yaml:"user"`
	Pass     string `json:"password" yaml:"password"`
	Database string `json:"database" yaml:"database"`
}

// FollowMessage 关注消息结构体
type FollowMessage struct {
	Action     string `json:"action"`
	FollowerID int    `json:"follower_id"`
	FollowedID int    `json:"followed_id"`
}

var config Config

func init() {
	// 读取 YAML 文件内容
	yamlFile, err := ioutil.ReadFile("../../etc/config.yaml")
	if err != nil {
		fmt.Printf("Error reading YAML file: %v\n", err)
		return
	}

	// 定义一个 CanalConfig 结构体实例
	err = yaml.Unmarshal(yamlFile, &config)
	if err != nil {
		fmt.Printf("Error unmarshaling YAML data: %v\n", err)
		return
	}
	fmt.Printf("kafka config: %v\n", config.Kafka)
	fmt.Printf("mysql config: %v\n", config.Mysql)
}
